package com.dysoft.flesh.gl;

import com.dysoft.flesh.RenderComponent;
import com.dysoft.flesh.RenderContext;

import javax.media.opengl.GL;
import javax.media.opengl.glu.GLU;

/**
 * @author Sean Micklethwaite
 *         Nov 2, 2010 6:54:05 PM
 */
public class GLOrthoProjection implements RenderComponent {
	protected final static GLU glu = new GLU();

	public void activate(RenderContext ctx) {
		GL gl = ((GLRenderer.GLRenderContext)ctx).getGL();

		gl.glMatrixMode(GL.GL_PROJECTION);
        gl.glLoadIdentity();

		glu.gluOrtho2D(0, ctx.getTarget().getWidth(), 0, ctx.getTarget().getHeight());
        gl.glScalef(1, -1,1);
        gl.glTranslatef(0, -ctx.getTarget().getHeight(), 0);

        gl.glMatrixMode(GL.GL_MODELVIEW);
		gl.glLoadIdentity();
	}

	public void deactivate(RenderContext ctx) {

	}
}
